package com.example.spring_mysql.controller

import org.springframework.scheduling.annotation.Async
import org.springframework.scheduling.annotation.EnableAsync
import org.springframework.stereotype.Service
import java.util.concurrent.CompletableFuture


@Service
class AsyncService {

    @Async
    fun doAsyncTask(name: String): CompletableFuture<String> {
        println("【AsyncService】线程: ${Thread.currentThread().name}")
        Thread.sleep(1000)
        throw RuntimeException("这是异步线程抛出的异常！")
        return CompletableFuture.completedFuture("success")
    }
}
